package com.ylr.admin.common.enums;

import com.ylr.base.common.dto.NameValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2023-05-09 21:32:11
 * className: DeptEnum
 * version: 1.0
 * description:
 */
@Getter
@AllArgsConstructor
public enum DeptEnum {

    NULL(null, null),

    // 排序等级
    ONE(1, "一级"), TWO(2, "二级"), THREE(3, "三级"), FOUR(4, "四级"), FIVE(5, "五级")
    ;

    /**
     * 值
     */
    private final Integer value;

    /**
     * 名称
     */
    private final String name;

    /**
     * 获取菜单类型枚举对象列表
     */
    public static List<NameValue<Integer>> getLevelEnumList() {
        List<NameValue<Integer>> list = new ArrayList<>();
        list.add(new NameValue<>(ONE.name, ONE.value));
        list.add(new NameValue<>(TWO.name, TWO.value));
        list.add(new NameValue<>(THREE.name, THREE.value));
        list.add(new NameValue<>(FOUR.name, FOUR.value));
        list.add(new NameValue<>(FIVE.name, FIVE.value));
        return list;
    }

    /**
     * 获取菜单类型枚举对象
     * @param value 值
     * @return 菜单类型枚举对象
     */
    public static DeptEnum getLevelEnum(Integer value) {
        if (ONE.value.equals(value)) {
            return ONE;
        }
        if (TWO.value.equals(value)) {
            return TWO;
        }
        if (THREE.value.equals(value)) {
            return THREE;
        }
        if (FOUR.value.equals(value)) {
            return FOUR;
        }
        if (FIVE.value.equals(value)) {
            return FIVE;
        }
        return NULL;
    }

    /**
     * 校验菜单类型值
     * @param value 值
     * @return true-错误 false-正确
     */
    public static boolean isLevelFail(Integer value) {
        return getLevelEnum(value) == NULL;
    }

}
